import { createStore } from 'redux'

// 仓库初始化数据
const initState = {
  count: 0,
  msg: '其他信息',
}

// reducer 函数签名是：(state, action) => newState
const reducer = (state = initState, action) => {
  switch (action.type) {
    case 'add':
      return { ...state, count: state.count + action.payload }
    default:
      return state
  }
}

// 创建仓库实例
const store = createStore(reducer)

// 导出仓库实例用于项目
export default store
